package math;

public class Matrice3D {
	
	private double a11,a12,a13;
	private double a21,a22,a23;
	private double a31,a32,a33;
	
	/*****************************************************************************
	 * note pour louis et sa pauvre résolution: "pas touche la mise en page!!!"
	 ****************************************************************************/
	
	
	/**
	 * @param a11
	 * @param a12
	 * @param a13
	 * @param a21
	 * @param a22
	 * @param a23
	 * @param a31
	 * @param a32
	 * @param a33
	 */
	public Matrice3D(double a11, double a12, double a13, double a21,
			double a22, double a23, double a31, double a32, double a33) {
		super();
		this.a11 = a11;
		this.a12 = a12;
		this.a13 = a13;
		this.a21 = a21;
		this.a22 = a22;
		this.a23 = a23;
		this.a31 = a31;
		this.a32 = a32;
		this.a33 = a33;
	}



	/**
	 * @param m
	 */
	public Matrice3D(double[][] m) {
		super();
		this.a11 = m[0][0]; this.a12 = m[0][1]; this.a13 = m[0][2];
		this.a21 = m[1][0]; this.a22 = m[1][1]; this.a23 = m[1][2];
		this.a31 = m[2][0]; this.a32 = m[2][1]; this.a33 = m[2][2];
	}
	


	public Matrice3D time(Matrice3D m){
		return new Matrice3D(
				a11*m.a11 + a12*m.a21 + a13*m.a31,	 a11*m.a12 + a12*m.a22 +a13*m.a32,	 a11*m.a13 + a12*m.a23 + a13*m.a33,
				a21*m.a11 + a22*m.a21 + a23*m.a31,	 a21*m.a12 + a22*m.a22 +a23*m.a32,	 a21*m.a13 + a22*m.a23 + a23*m.a33,
				a31*m.a11 + a32*m.a21 + a33*m.a31,	 a31*m.a12 + a32*m.a22 +a33*m.a32,	 a31*m.a13 + a32*m.a23 + a33*m.a33		
		);
		
	}	
	
	public Matrice3D add(Matrice3D m){
		return new Matrice3D(
				a11 + m.a11,	a12 + m.a12,	a13 + m.a13,
				a21 + m.a21,	a22 + m.a22,	a23 + m.a23,
				a31 + m.a31,	a32 + m.a32,	a33 + m.a33
		);
		
	}
	
	public void thisAdd(Matrice3D m){
		a11 +=m.a11;	a12+=m.a12;		a13=m.a13;
		a21 +=m.a21;	a22+=m.a22;		a23=m.a23;
		a31 +=m.a31;	a32+=m.a32;		a33=m.a33;
	}
	
	public double det(){
		return a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31)   ;
	
	}
   public double trace(){
	   return a11+a22+a33;
   }
}
